import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;


public class Monitor {
	private BufferedReader bf;
	private int _current = 1;
	public Monitor() throws FileNotFoundException{
		bf=new BufferedReader(new FileReader("a.txt"));
	}
	
	public synchronized void getNumber(int _number) throws InterruptedException, IOException {
		while (_current != _number) {
			wait();
		}
		System.out.println("Numer watku: "+_number+" Wartosc:" + bf.readLine());
		_current++;
		notifyAll();
	}
}
